

layui.use(['form', 'admin', 'ax','laydate'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var laydate = layui.laydate;

    //让当前iframe弹层高度适应
    admin.iframeAuto();

    //表单提交事件 通过
    form.on('submit(pass)', function (data) {
        var index;
        $.ajax({
        	url:Feng.ctxPath + "/outOrder/audit?whether="+1,
        	cache: false,
        	dataType:"json",
        	data:data.field,
        	beforeSend:function(){
            	//弹出加载中
        		index = layer.msg('审核中。。。请耐心等待', {
      			  icon: 16,
      			  shade: [0.2,'#000'], //0.1透明度的白色背景
      			  time: false
        		});
        	},
        	success:function(data){
            	layer.close(index); 
                var Indexs = parent.layer.getFrameIndex(window.name);
        		if (data.success) {
                    parent.layer.close(Indexs);
                    Feng.success("更新成功！");
				} else {
					if (data.message !=null &&data.message!='') {
	    				var msg =  layer.open({
		  					  title: '提示' ,
		  					  content: data.message,
		  					  btn: ['确定'],
		  					  yes: function (){
		  						  	layer.close(msg);
		  			                parent.layer.close(Indexs);
		  			                Feng.success("更新失败！");
		  					  }
	    				});     
					} else {
			                Feng.success("更新失败！");
					}
				}
        	},
        	error:function(data){
            	layer.close(index); 
            	var Indexs = parent.layer.getFrameIndex(window.name);
                parent.layer.close(Indexs);
                Feng.error("更新失败！")
        	}
        })
        return false;
    });

    //表单提交事件 驳回
    form.on('submit(returnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/outOrder/audit?whether="+2, function (data) {
            Feng.success("驳回成功！");
            var Index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(Index);
        }, function (data) {
            Feng.error("驳回失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });

    form.verify({
        returnNote: function(value, item){ //value：表单的值、item：表单的DOM对象
            if(value.length>255){
                return '字数超出255';
            }
        }
    });

    //返回按钮
    $("#backupPage").click(function () {
        var Index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(Index);
    });

});